﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using BookShop3Tables.Models;

namespace BookShop3Tables.DAL
{
    public class BookInitializer : DropCreateDatabaseIfModelChanges<BookContext>
    {
        protected override void Seed(BookContext context)
        {
            var authors = new List<Author>
            {
                new Author { FirstName = "Terry", LastName = "Gookind" },           // ID 1
                new Author { FirstName = "J.R.R.", LastName ="Tolkien" },           // ID 2
                new Author { FirstName = "Trudi", LastName ="Canavan" },            // ID 3
                new Author { FirstName = "Peter V.", LastName ="Brett" },           // ID 4
                new Author { FirstName = "Jonathan", LastName ="Stroud" },          // ID 5
                new Author { FirstName = "Kevin", LastName ="Hearne" },             // ID 6     
                new Author { FirstName = " William", LastName ="Shakespeare" },     // ID 7
                new Author { FirstName = "Tennessee", LastName ="Williams" },       // ID 8
                new Author { FirstName = "Henrik", LastName ="Ibsen" },             // ID 9                
                new Author { FirstName = "Michael", LastName ="Connelly" },         // ID 10
                new Author { FirstName = "Sue", LastName ="Grafton" },              // ID 11
                new Author { FirstName = "Stieg", LastName ="Larsson" },            // ID 12
                new Author { FirstName = "D.D.", LastName ="Barant" },              // ID 13
                new Author { FirstName = "Val", LastName ="McDermid" },             // ID 14         
                new Author { FirstName = "Stephenie", LastName ="Meyer" },          // ID 15
                new Author { FirstName = "E.L.", LastName ="James" },               // ID 16
                new Author { FirstName = "Nicholas", LastName ="Sparks" },          // ID 17
                new Author { FirstName = "Margaret", LastName ="Mitchell" },        // ID 18
                new Author { FirstName = "Ally", LastName = "Condie"}               // ID 19
            };
            authors.ForEach(a => context.Authors.Add(a));
            context.SaveChanges();

            var categories = new List<Category>
            {
                
				new Category { Name = "Fantasy" },
                new Category { Name = "Drama" },
                new Category { Name = "Criminal" },
                new Category { Name = "Romance" }
            };
            categories.ForEach(a => context.Categories.Add(a));
            context.SaveChanges();

            var books = new List<Book>
            {

                new Book {CategoryID = 1, PersonID = 1, Name = "Wizard's First Rule, Vol 1", Saga = "Seeker of Truth", Price = 6.29M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Stone of Tears, Vol 2", Saga = "Seeker of Truth", Price = 6.89M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Blood of the Fold, Vol 3", Saga = "Seeker of Truth", Price = 6.29M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Temple of the Winds, Vol 4", Saga = "Seeker of Truth", Price = 6.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Soul of the Fire, Vol 5", Saga = "Seeker of Truth", Price = 6.89M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Faith of the Fallen, Vol 6", Saga = "Seeker of Truth", Price = 6.89M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "The Pillars of Creation, Vol 7", Saga = "Seeker of Truth", Price = 6.29M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Naked Empire, Vol 8", Saga = "Seeker of Truth", Price = 3.72M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Chainfire, Vol 9", Saga = "Seeker of Truth", Price = 6.29M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Phantom, Vol 10", Saga = "Seeker of Truth", Price = 6.74M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "Confessor, Vol 11", Saga = "Seeker of Truth", Price = 4.74M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 1, Name = "The Omen Machine, Vol 12", Saga = "Seeker of Truth", Price = 6.29M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 2, Name = "Hobbit", Saga = "None", Price = 3.84M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 2, Name = "The Fellowship of the Ring, Vol 1", Saga = "Lord of the Rings", Price = 12.80M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 2, Name = "The Two Towers, Vol 2", Saga = "Lord of the Rings", Price = 12.80M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 2, Name = "The Return of the King, Vol 3", Saga = "Lord of the Rings", Price = 12.18M, ReleaseDate = DateTime.Parse("12/12/2000")},                
                new Book {CategoryID = 1, PersonID = 3, Name = "The Magician's Apprentice, Vol 0.5", Saga = "Black Mage Trillogy", Price = 9.40M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 3, Name = "The Magicians' Guild, Vol 1", Saga = "Black Mage Trillogy", Price = 4.84M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 3, Name = "The Novice, Vol 2", Saga = "Black Mage Trillogy", Price = 5.59M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 3, Name = "The High Lord, Vol 3", Saga = "Black Mage Trillogy", Price = 6.29M, ReleaseDate = DateTime.Parse("12/12/2000")},                
                new Book {CategoryID = 1, PersonID = 3, Name = "The Ambassador's Mission, Vol 1", Saga = "The Traitor Spy Trilogy", Price = 10.59M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 3, Name = "The Rogue, Vol 2", Saga = "The Traitor Spy Trilogy", Price = 11.59M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 3, Name = "The Traitor Queen, Vol 3", Saga = "The Traitor Spy Trilogy", Price = 11.39M, ReleaseDate = DateTime.Parse("12/12/2000")},                
                new Book {CategoryID = 1, PersonID = 4, Name = "The Painted Man, Vol 1", Saga = "The Demon Cycle", Price = 6.74M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 4, Name = "The Desert Spear, Vol 2", Saga = "The Demon Cycle", Price = 6.20M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 4, Name = "The Daylight War, Vol 3", Saga = "The Demon Cycle", Price = 11.77M, ReleaseDate = DateTime.Parse("12/12/2000")},                
                new Book {CategoryID = 1, PersonID = 5, Name = "Heroes of the Valley", Saga = "None", Price = 5.24M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 6, Name = "Hounded, Vol 1", Saga = "The Iron Druid Chronicles", Price = 5.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 6, Name = "Hexed, Vol 2", Saga = "The Iron Druid Chronicles", Price = 5.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 6, Name = "Hammered, Vol 3", Saga = "The Iron Druid Chronicles", Price = 5.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 6, Name = "Tricked, Vol 4", Saga = "The Iron Druid Chronicles", Price = 5.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 6, Name = "Trapped, Vol 5", Saga = "The Iron Druid Chronicles", Price = 5.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 1, PersonID = 6, Name = "Hunted, Vol 6", Saga = "The Iron Druid Chronicles", Price = 7.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 2, PersonID = 7, Name = "Hamlet", Saga = "None", Price = 5.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 2, PersonID = 7, Name = "Macbeth", Saga = "None", Price = 5.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 2, PersonID = 8, Name = "The Glass Menagerie", Saga = "None", Price = 6.74M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 2, PersonID = 9, Name = "A Doll's House", Saga = "None", Price = 3.45M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 3, PersonID = 10, Name = "Echo Park", Saga = "None", Price = 5.99M, ReleaseDate =DateTime.Parse("12/12/2000") },
                new Book {CategoryID = 3, PersonID = 11, Name = "S is for Silence", Saga = "None", Price = 8.80M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 3, PersonID = 12, Name = "The Girl with the Dragon Tattoo, Vol 1", Saga = " Millennium series trilogy", Price = 5.03M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 3, PersonID = 12, Name = "The Girl Who Played with Fire, Vol 2", Saga = " Millennium series trilogy", Price = 4.27M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 3, PersonID = 12, Name = "The Girl Who Kicked the Hornet's Nest, Vol 3", Saga = " Millennium series trilogy", Price = 3.84M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 3, PersonID = 13, Name = "Dying Bites", Saga = "None", Price = 5.24M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 3, PersonID = 14, Name = "A Darker Domain", Saga = "None", Price = 5.59M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 15, Name = "Twilight, Vol 1", Saga = "Twilight", Price = 5.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 15, Name = "New Moon, Vol 2", Saga = "Twilight", Price = 5.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 15, Name = "Eclipse, Vol 3", Saga = "Twilight", Price = 5.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 15, Name = "Breaking Dawn, Vol 4", Saga = "Twilight", Price = 5.19M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 16, Name = "Fifty Shades of Grey, Vol 1", Saga = "Fifty Shades", Price = 3.85M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 16, Name = "Fifty Shades Darker, Vol 2", Saga = "Fifty Shades", Price = 3.85M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 16, Name = "Fifty Shades Freed, Vol 3", Saga = "Fifty Shades", Price = 3.85M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 17, Name = "A Walk to Remember", Saga = "None", Price = 5.59M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 17, Name = "Dear John", Saga = "None", Price = 5.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 4, PersonID = 18, Name = "Gone with the Wind", Saga = "None", Price = 6.49M, ReleaseDate = DateTime.Parse("12/12/2000")},               
                new Book {CategoryID = 2, PersonID = 19, Name = "Matched, Vol 1", Saga = "Matched", Price = 4.99M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 2, PersonID = 19, Name = "Crossed, Vol 2", Saga = "Matched", Price = 5.24M, ReleaseDate = DateTime.Parse("12/12/2000")},
                new Book {CategoryID = 2, PersonID = 19, Name = "Reached, Vol 3", Saga = "Matched", Price = 6.89M, ReleaseDate = DateTime.Parse("12/12/2000")}
            };
            books.ForEach(a => context.Books.Add(a));
            context.SaveChanges();

        }
    }
}

